package com.jadows.tdog.message.action;

import com.jadows.tdog.constants.GlobalActions;
import com.jadows.tdog.domain.ChatMessage;
import com.jadows.tdog.message.WsReqWrapper;
import com.jadows.tdog.message.annotations.Action;
import com.jadows.tdog.message.details.AbstractMessage;
import com.jadows.tdog.message.details.DirectTextMessage;
import com.jadows.tdog.message.details.RoomTextMessage;
import com.jadows.tdog.message.handler.impl.DirectTextMessageHandler;
import com.jadows.tdog.message.handler.impl.MessageReadHandler;
import com.jadows.tdog.message.handler.impl.RoomTextMessageHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;

/**
 * @author taojiacheng
 */
@Controller
@RequiredArgsConstructor
public class WSChatActionsHandler {

    final DirectTextMessageHandler directTextMessageHandler;
    final RoomTextMessageHandler roomTextMessageHandler;
    final MessageReadHandler messageReadHandler;

    /**
     * 私聊文本消息
     */
    @Action(GlobalActions.DIRECT_TEXT_MSG)
    public ChatMessage directTextMsg(WsReqWrapper<DirectTextMessage> reqWrapper) {
        return directTextMessageHandler.handleDirectTextMessage(reqWrapper);
    }

    /**
     * 群聊文本消息
     */
    @Action(GlobalActions.ROOM_TEXT_MSG)
    public void roomTextMsg(WsReqWrapper<RoomTextMessage> reqWrapper) {
        roomTextMessageHandler.handleRoomTextMessage(reqWrapper);
    }

    /**
     * 消息确认[已读]
     */
    @Action(GlobalActions.DIRECT_TEXT_MSG_READ)
    public void readMessage(WsReqWrapper<AbstractMessage> reqWrapper) {
        messageReadHandler.readMessage(reqWrapper);
    }

}
